/**
 * Computer Network, Programming Assignment #2
 * 
 * Point Class
 * @author Yancheng Li
 *
 */

public class Point {
	private Integer x;
	private Integer y;
	
    /*@Override
	public int hashCode() {
        int hashFirst = x != null ? x.hashCode() : 0;
        int hashSecond = y != null ? y.hashCode() : 0;

        return (hashFirst + hashSecond) * hashSecond + hashFirst;
    }*/
    
	Point(int x, int y){
		this.x = x;
		this.y = y;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}
	
	@Override
	public String toString(){
		return "(" + x + ", " + y + ")";
	}
	
	@Override
	public boolean equals(Object other){
		if(this == other)
			return true;
		
		if(!(other instanceof Point))
			return false;
			
		Point a = (Point)other;
		return x == a.getX() && y == a.getY();
	}
	
	@Override
	public int hashCode(){
		
		return x*3 + y;
		
	}
}
